import Axios from 'axios'
// import request from '@/utils/request'
import { request } from '@/utils/request-fetch'
const cfgBaseUrl = process.env.VUE_APP_CFG_API
const VUE_APP_BASE_API = process.env.VUE_APP_BASE_API
const FREE_TOKEN_ACT_ID = '60000MT'
// 获取配置后台的配置
export function getBackEndConfig (params) {
  return Axios({
    baseURL: cfgBaseUrl,
    url: `/api/v1/cs/configdata`,
    method: 'get',
    params
  })
}
export function getMonthTokenDrawStatus () {
  return request(
    'GET',
    `${VUE_APP_BASE_API}/api/v1/activity/month-token/draw-qualification`,
    {
      act_fixed_id: FREE_TOKEN_ACT_ID
    },
    { user: true }
  )
}
/**
 * 会员领取每月token
 * http://192.168.88.247:4999/web/#/105?page_id=2514
 */
export function getUserFreeToken () {
  return request(
    'POST',
    `${VUE_APP_BASE_API}/api/v1/activity/month-token/draw`,
    {
      act_fixed_id: FREE_TOKEN_ACT_ID
    },
    { user: true }
  )
}

// 获取权益
export function getRights (data) {
  return request('GET', VUE_APP_BASE_API + '/api/v1/member/rights', data, { user: true })
}
// 是否VIP会员
export function getMemberInfo () {
  return request('GET', `${VUE_APP_BASE_API}/api/v1/member/info`, null, { user: true })
}
// 获取可用token
export function getUserToken () {
  const unit_id = {
    'yueshu': 'token',
    'dll': 'dllenergy',
    'repairmaster': 'dllenergy',
    'xz': 'xzenergy'
  }[process.env.VUE_APP_NAME]
  // process.env.VUE_APP_NAME === 'xz' ? 'xzenergy' : 'token'
  return request('GET', VUE_APP_BASE_API + '/charge/api/v1/user/charge_info', { unit_id }, { user: true })
}

/**
 * 查看用户活动领取情况
 * http://192.168.88.247:4999/web/#/105/3040 密码: RR8pUR67
 * @returns
 */
export function getUserActivity (params) {
  return request('GET', VUE_APP_BASE_API + '/api/v1/activity/user_activity_info', params, { authBear: true })
}

/**
 * 查看活动详情
 * http://192.168.88.247:4999/web/#/105/2846 密码: RR8pUR67
 * @returns
 */
export function getActivityDetail (params) {
  return request('GET', VUE_APP_BASE_API + '/api/v1/activity/detail', params, { authBear: true })
}
